package com.ysd.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.ysd.entity.Productcategory;
import com.ysd.utli.DBManager;

public class ChanPinDaoImpl {
	public List<Productcategory> getProductcategory(int pid){
		List<Productcategory> List = new ArrayList<Productcategory>();
		Connection conn=DBManager.getConnection();
		Statement st=null;
		ResultSet rs=null;
		try {
			st = conn.createStatement();
			rs = st.executeQuery("select * from Productcategory where productCategoryld="+pid);
			while(rs.next()){
				int productCategoryld = rs.getInt("productCategoryld");
				String productCategoryName = rs.getString("productCategoryName");
				String productCategoryimg = rs.getString("productCategoryimg");
				Productcategory productcategory = new Productcategory(productCategoryld, productCategoryName, productCategoryimg);
				List.add(productcategory);
			}
			return List;
		} catch (SQLException e) {
			e.printStackTrace();
			return null;
		}finally {
			DBManager.closeAll(conn, st, rs);
		}
	}
}